package samples
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.utils.clearInterval;
	
	/**
	 * ...
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class BaseSample extends Sprite
	{
		private var _sw:Number;
		private var _sh:Number;
		private var _color:uint = 0xFFFFFF;
		public var interval:int;
		
		public function BaseSample() 
		{
			
			if ( _stage == null )
			{
				_stage = stage;
				_stage.scaleMode = StageScaleMode.NO_SCALE;
				_stage.align = StageAlign.TOP_LEFT;
			}
			sw = _stage.stageWidth;
			sh = _stage.stageHeight;
			addEventListener( Event.REMOVED_FROM_STAGE, removeInterval );
			
		}
		
		private function removeInterval(e:Event):void 
		{
			removeEventListener(Event.REMOVED_FROM_STAGE, removeInterval);
			clearInterval( interval );
			graphics.clear();
			while ( numChildren ) removeChildAt( 0 );
		}
		
		public function center():void
		{
			this.x = _stage.stageWidth / 2 - width / 2;
			this.y = _stage.stageHeight / 2 - height / 2;
		}
		
		public function get sw():Number { return _sw; }
		
		public function set sw(value:Number):void 
		{
			_sw = value;
		}
		
		public function get sh():Number { return _sh; }
		
		public function set sh(value:Number):void 
		{
			_sh = value;
		}
		
		public function get color():uint { return _color; }
		
		public function set color(value:uint):void 
		{
			_color = value;
		}
		
	}

}